var Paddle = function(game) {
    var o = game.imageByName('paddle')
    //var o = {
    //    image:image,
    //    x:100,
     //   y:270,
     //   speed:5
    //}
    o.x = 100
    o.y = 270
    o.speed = 15
    var paddle = o
    o.move = function(x)
    {  
        if(x < 0)
        {
            x = 0
        }

        if(x > 400 - o.image.width)
        {
            x =  400 - o.image.width
        }
        o.x = x

    }

    o.moveLeft = function () {
        //log('move left')
        o.move(o.x-o.speed)
    }

    o.moveRight = function () {
       // o.x += o.speed
        o.move(o.x + o.speed)
    }

    o.collide = function (ball) {

        if (ball.y + ball.image.height > o.y ) {
            if (ball.x > o.x && ball.x < o.x + o.image.width){
                log('相撞')
                return true
            }
        }

        return false
    }

    return o
}